package com.leyou.item.client;

import com.leyou.common.vo.PageResult;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient("item-service")
public interface ItemClient {
    //- 第一：分批查询spu的服务。
    //查询商品SPU信息 ，分页查询
    @GetMapping("/spu/page")
    public PageResult<SpuDTO> querySpuByPage(
            @RequestParam(value = "key",required = false)String key,
            @RequestParam(value = "page",defaultValue = "1")Integer page,
            @RequestParam(value = "rows",defaultValue = "5")Integer rows,
            @RequestParam(value = "saleable",required = false)Boolean saleable
    );

    //- 第二：根据spuId查询sku的服务
    //回显商品sku数据
    @GetMapping("/sku/of/spu")
    public List<SkuDTO> querySku(@RequestParam("id")Long spuId);

    //- 第三：根据spuId查询SpuDetail的服务
    //回显商品spuDetail数据
    @GetMapping("/spu/detail")
    public SpuDetailDTO querySpuDetail(@RequestParam("id")Long spuId);

    //- 第四：根据商品分类id，查询商品分类。
    // 根据id的集合查询商品分类
    @GetMapping("/category/list")
    public List<CategoryDTO> queryCategoryByIds(@RequestParam(value = "ids") List<Long> ids);

    //- 第五：查询分类下可以用来搜索的规格参数
    //查询规格参数
    @GetMapping("/spec/params")
    public List<SpecParamDTO> querySpecParam(
            @RequestParam(value = "gid",required = false)Long gid,
            @RequestParam(value = "cid",required = false)Long cid,
            @RequestParam(value = "searching",required = false)Boolean searching);

    //- 第六：根据id查询品牌
    //根据ID查询品牌信息
    @GetMapping("/brand/{id}")
    public BrandDTO queryBrandId(@PathVariable("id")Long id);

    //根据id的集合查询商品品牌
    @GetMapping("/brand/list")
    public List<BrandDTO> queryBrandByIds(@RequestParam(value = "ids")List<Long> ids);

    //根据id查询spu
    @GetMapping("/spu/{id}")
    public SpuDTO querySpuById(@PathVariable("id")Long id);

    @GetMapping("/spec/of/category")
    public List<SpecGroupDTO> querySpecsByCid(@RequestParam("id") Long id);

}
